
Chapter 33. Using Web Service APIs

From the website:

  Killer Game Programming in Java
  http://fivedots.coe.psu.ac.th/~ad/jg

  Dr. Andrew Davison
  Dept. of Computer Engineering
  Prince of Songkla University
  Hat yai, Songkhla 90112, Thailand
  E-mail: ad@fivedots.coe.psu.ac.th


If you use this code, please mention my name, and include a link
to the website.

Thanks,
  Andrew

============================

An application which sends a book title to Yahoo's Shopping 
service, and gets back a PNG image of the book's cover. 
	- uses Yahoo's Product Search API

This version returns data in JSON format.


This directory contains:

  * SearchJYahoo.java
	- does the search 
        - you MUST MODIFY the APP_ID line
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
	- use the key assigned to you by Yahoo (see "Getting a Key" below)

  * WebUtils.java
	- useful support methods 

  * NamespaceContextImpl.java
	- for XML namespace contexts (by Deepak Vohra)


  * jackson-core-lgpl-1.0.0.jar, 
    jackson-mapper-lgpl-1.0.0.jar
       - from http://jackson.codehaus.org/  (details below)

  * commons-jxpath-1.3.jar
       - from http://commons.apache.org/jxpath/  (details below)


There are 2 batch files:

  * compile.bat

  * run.bat
     - you MUST MODIFY its proxy settings to suit you
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  - both batch files assume that jackson-core-lgpl-1.0.0.jar, 
    jackson-mapper-lgpl-1.0.0.jar, and
    commons-jxpath-1.3.jar are in the local directory

----------------------------
Getting a Key

Go to Yahoo! Shopping Web Services
  http://developer.yahoo.com/shopping/
  
Get an Application ID by pressing on the "Get an App ID" button.

----------------------------
API Information

Product Search API v3
  http://developer.yahoo.com/shopping/V3/productSearch.html

Yahoo Java developer site
  http://developer.yahoo.com/java/

Yahoo! Shopping Developer Support Group
  http://tech.groups.yahoo.com/group/yws-shopping/

 
----------------------------
Jackson Installation
  http://jackson.codehaus.org/

Download version 1.0.0 (or later)
  - select LGPL: core-lgpl *AND* mapper-lgpl
  - this will retrieve jackson-core-lgpl-1.0.0.jar *AND* 
                       jackson-mapper-lgpl-1.0.0.jar  (or later)

Move the two JARs to the local directory.

Tutorial
  http://jackson.codehaus.org/Tutorial

API docs
  http://jackson.codehaus.org/1.0.0/javadoc/index.html


----------------------------
JXPath Installation
  http://commons.apache.org/jxpath/

Download zipped binary v1.3., commons-jxpath-1.3-bin.zip

Unzip, and move commons-jxpath-1.3.jar to the local directory.


User guide
  http://commons.apache.org/jxpath/users-guide.html

API Docs
  http://commons.apache.org/jxpath/apidocs/index.html
  - JXPathContext API page has some useful examples

----------------------------
Compilation:

  > compile *.java

- this generates an unchecked warning in SearchJYahoo.java due to 
  generic casting; it can be ignored

----------------------------
Execution:

  > run SearchJYahoo <book title>
e.g.

  > run SearchJYahoo "killer game programming in java"


It will download a book cover, and create a JSON file called temp.json

---------
Last updated: 1st July 2009
